package com.xiaoyao.novel.common;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xiaoyao.novel.util.ClassUtil;

/**
 * 分页
 * 
 * @author 旷明爱
 * @date Dec 17, 2012 9:16:34 AM
 */
@SuppressWarnings("unchecked")
public class Pagin {
	// 分页参数
	int pageNow = 1;// //////////////////////
	int pageSize = 50;
	int start = 0;
	int pageCount;// 总页数
	int rowCount;// 行数
	// 分页结果
	List list;
	// 参数
	Map<String, String> searchParam = new HashMap<String, String>();

	public Pagin() {
		super();
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public Map<String, String> getSearchParam() {
		if (searchParam == null) {
			searchParam = new HashMap<String, String>();
		}
		String endTime = searchParam.get("endTime");
		if (!ClassUtil.isEmpty(endTime) && !endTime.contains(" ")) {
			searchParam.put("endTime", endTime + " 23:59:59");
		}
		return searchParam;
	}

	public void setSearchParam(Map<String, String> searchParam) {
		this.searchParam = searchParam;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageNow() {
		return pageNow;
	}

	public void setPageNow(int pageNow) {
		if (pageNow < 1) {
			pageNow = 1;
		}
		this.pageNow = pageNow;
	}

	public int getStart() {
		start = (pageNow - 1) * pageSize;
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getPageCount() {
		pageCount=(rowCount-1)/pageSize +1;
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public int getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
	}

}
